﻿using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Razor.TagHelpers;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using Xfm.TagHelpers.Exts;

namespace Xfm.TagHelpers
{
    /// <summary>
    /// 核心功能还是使用mvc默认的InputTagHelper,这里只对样式做修改
    /// <see cref="Microsoft.AspNetCore.Mvc.TagHelpers.InputTagHelper"/>
    /// </summary>
    [HtmlTargetElement("input", TagStructure = TagStructure.WithoutEndTag)]
    public class IptTagHelper : TagHelper
    {

        //public IptTagHelper(IHtmlGenerator generator)
        //{
        //    Generator = generator;
        //}
        public override int Order => 1;//越小先执行，mvc框架的InputTagHelper:-1000
        //protected IHtmlGenerator Generator { get; }
        public override Task ProcessAsync(TagHelperContext context, TagHelperOutput output)
        {
            if (context == null)
            {
                throw new ArgumentNullException(nameof(context));
            }

            if (output == null)
            {
                throw new ArgumentNullException(nameof(output));
            }
            output.AddClass("form-control");
            return Task.CompletedTask;
        }
    }
}
